home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / arexx / arexg10c.lha / ARexxGuide / Extras / ARx_Help.ttx < prev    next >
Encoding:
Text File  |  1993-10-14  |  19.9 KB  |  611 lines

  1. /** $VER: ARx_Help.ttx 1.1 (14 Oct 1993)
  2.  ** by Robin Evans (based on getxref.ttx by David N. Junod)
  3.  **
  4.  ** Display the ARexxGuide page for the word currently under the
  5.  ** cursor.
  6.  **
  7.  ** Add the following line to your TTX_Startup.dfn file, in the KEYBOARD:
  8.  ** section.
  9.  **
  10.  **     HELP               ExecARexxMacro "ARx_Help" SYNC
  11.  **     SHIFT-HELP         ExecARexxMacro "ARx_Help" ASYNC
  12.  **
  13.  ** You may want to add the following lines to your S:user-startup file.
  14.  **
  15.  **   RXLIB amigaguide.library 0 -30
  16.  **
  17.  ** Be careful with that library, however. I've found that it interferes
  18.  ** in some cases with rexxarplib.library. If that happens, it can be
  19.  ** removed with this shell command:
  20.  **
  21.  **   RX "remlib('amigaguide.library')
  22.  **
  23.  **  The AmigaGuide/path environmental variable must include the directory
  24.  **  where arx_guide.xref is located.
  25.  **  the ARexxGuide/AGCmd environmental variable must include the name
  26.  **  of the command used to launch amigaguide files.
  27.  **/
  28.  
  29. signal on syntax
  30. signal on break_c
  31. signal on halt
  32. signal on failure
  33.  
  34.    /* If you'd rather not use rexxarplib, see the alternative subroutine **
  35.    ** for ShowInfo: near line 340. If you uncomment the alternative,     **
  36.    ** then rexxarplib won't be needed. Delete the following two lines to **
  37.    ** keep it from being loaded.                                         */
  38. if ~show('L','rexxarplib.library') then
  39.     call addlib('rexxarplib.library',0,-30)
  40.  
  41. TRUE=1; FALSE=0
  42.  
  43.    /* We're using SetInputLock, so we should make sure it doesn't stay on */
  44. signal on break_c
  45. signal on halt
  46. signal on syntax
  47. signal on failure
  48.  
  49. options results
  50. parse arg Mode LkUp
  51.  
  52. if ~show('L','amigaguide.library') then
  53.     call addlib('amigaguide.library',0,-30)
  54.  
  55. if ~show('L','rexxsupport.library') then
  56.     call addlib('rexxsupport.library',0,-30)
  57.  
  58.    /* Did they pass a word? */
  59. if LkUp = '' then do
  60.  
  61.       /* Get all the line info we'll need and lock out input until **
  62.       ** it's all collected.                                       **
  63.       ** Check for special characters first                        */
  64.    'SetInputLock on'
  65.    'GetLine 1'
  66.    HLine = Tab2Space(result)
  67.    'GetCursorPos'
  68.    CurPos = word(result, 2)
  69.    'SetInputLock off'
  70.       /* Show the index requester if it's a blank line */
  71.    if HLine = '' | verify(HLine, ' ;') = 0 then do
  72.       call ShowInfo(,, CurPos, Kwd)
  73.       exit
  74.    end
  75.       /* CurPos won't match ARexx count if tabs are used        **
  76.       ** this will break if a semicolon is used within a string **
  77.       ** but checking for that seems like overkill.             */
  78.    SemPos = lastpos(';', HLine, CurPos) + 1
  79.    Kwd = upper(word(HLine, 1))
  80.    if SemPos > 1 then
  81.       if SemPos < CurPos + 1 then do
  82.          parse var HLine =SemPos HLine ';'
  83.          CurPos = CurPos - SemPos + 1
  84.       end                                /* Hex characters:  ' ? ! . SpTbRt    */
  85.    MChar = pos(substr(HLine,CurPos,1), '+-/*|&^><=,;:~)("'||'273F212E20090a'x)
  86.    select
  87.       when MChar = 0 then do
  88.             /* Look for whole word if it isn't a special character */
  89.          'GetWord'
  90.          LkUp = result
  91.       end
  92.       when MChar <= 2 then
  93.          if Kwd = 'PARSE' then
  94.             LkUp = 'PARSETMP5'
  95.          else
  96.             LkUp = 'ARITHMETIC'
  97.       when MChar <= 4 then do
  98.             /* This picks up the three characters surrounding a '*' or '/' */
  99.          ComChar = substr(HLine, max(1, CurPos - 1), 3)
  100.          if pos('/*', ComChar) + pos('*/', ComChar) > 0 then
  101.             LkUp = 'COMMENT'
  102.          else
  103.             LkUp = 'ARITHMETIC'
  104.       end
  105.       when MChar <= 7 then
  106.          LkUp = 'LOGICAL'
  107.       when MChar <= 9 then
  108.          LkUp = 'COMPARISON'
  109.       when MChar = 10 then
  110.          if Kwd = 'PARSE' then
  111.             LkUp = 'PARSETMP5'
  112.          else if symbol(strip(left(HLine, max(1, CurPos-1)))) == 'BAD' then
  113.             LkUp = 'COMPARISON'
  114.          else
  115.             LkUp = 'ASSIGNMENT'
  116.       when MChar = 11 then
  117.          LkUp = 'COMMA'
  118.       when MChar = 12 then
  119.          LkUp = 'SEMICOLON'
  120.       when MChar = 13 then
  121.          LkUp = 'LABEL'
  122.       when MChar = 14 then do    /* Tilde           */
  123.             /* is the next character a comparison operator? */
  124.          if pos(substr(HLine, CurPos , 2), '~=~>~<') > 0 then
  125.             LkUp = 'COMPARISON'
  126.          else
  127.             LkUp = 'LOGICAL'
  128.       end
  129.       when MChar <=16 then
  130.          if Kwd = 'PARSE' then
  131.             LkUp = 'PARSETMP5'
  132.          else
  133.             LkUp = 'PAREN'
  134.       when MChar <= 18 then      /* Quotation marks */
  135.          LkUp = 'STRING'
  136.       when MChar = 19 then       /* ? */
  137.           if Kwd = 'TRACE' then
  138.               LkUp = 'TRACEOPT1'
  139.           else
  140.               LkUp = '?'
  141.       when MChar = 20 then            /* ! */
  142.           if Kwd = 'TRACE' then
  143.               LkUp = 'TRACEOPT2'
  144.           else
  145.               LkUp = '!'
  146.         when MChar = 21 then do   /* . -- dot  */
  147.                 /* Get the surrounding ARexx token */
  148.             StPos = verify(' 'HLine, '+-|/&=~\><^,;:()"'' ', 'M', lastpos(' ', ' 'HLine, CurPos))
  149.             Token = substr(HLine, StPos, verify(HLine' ', '+-|/&=~\><^,;:()"'' ', M, CurPos) - StPos)
  150.             if Token = '.' then
  151.                 if Kwd = 'PARSE' then
  152.                     LkUp = 'PARSETMP2'
  153.                 else
  154.                     LkUp = Token
  155.             else
  156.                LkUp = Token
  157.       end
  158.       otherwise /* At a space or EOL */
  159.          if CurPos >= wordindex(HLine, 1) then do
  160.             'GetWord'
  161.             LkUp = result
  162.          end
  163.          else do
  164.             call ShowInfo(HLine,, CurPos, Kwd)
  165.             exit
  166.          end
  167.    end
  168. end
  169.    /* Show that we're doing something */
  170. 'SetStatusBar TEMPORARY Checking for 'LkUp'...'
  171.  
  172.    /* See if the ARexxGuide cross-reference table is loaded **
  173.     ** Look for a ref that's not likely to be dup. in other  **
  174.    ** xref files.                                           */
  175. if getxref('TRACEOPT2') = 10 then do
  176.       /* Show that we're doing something */
  177.    'SetStatusBar TEMPORARY Loading cross-reference file...'
  178.       /* The ARexxGuide table wasn't loaded, so load it. */
  179.    if ~LoadXRef('ARx_Guide.xref') then
  180.        signal XRefError
  181. end
  182.  
  183. if word(HLine, 1) ~= LkUp then do CheckOpt = 1 for 1    /* Let's us leave */
  184.    if GetXRef(LkUp) = 10 | find('ARG PULL UPPER COMMAND', upper(LkUp)) > 0 then do
  185.       if word(GetXRef(Kwd),3) = 2 then select
  186.          when Kwd = 'DO' then do
  187.             SpecWord = find('UNTIL WHILE TO FOR BY FOREVER ', upper(LkUp))
  188.             if SpecWord > 0 then
  189.                LkUp = word('DOOPT4 DOOPT4 DOOPT2 DOOPT3 DOOPT2 DOOPT5', SpecWord)
  190.          end
  191.          when Kwd = 'PARSE' then do
  192.             SpecWord = find('ARG PULL EXTERNAL NUMERIC SOURCE VERSION VALUE VAR WITH', upper(LkUp))
  193.             if SpecWord > 0 then do
  194.                LkUp = 'PARSESRC'SpecWord
  195.                if SpecWord = 9 then
  196.                   LkUp = 'PARSESRC7'
  197.             end
  198.             else
  199.                 LkUp = 'PARSETMP1'
  200.          end
  201.          when Kwd = 'OPTIONS' then
  202.             if find('RESULTS PROMPT FAILAT CASHE ON OFF', upper(LkUp)) > 0 then
  203.                LkUp = Kwd
  204.          when Kwd = 'TRACE' then
  205.             if verify(upper(left(LkUp,1)), 'IRACLENOBS') = 0 then
  206.                LkUp = 'TRACEOPT'
  207.          when Kwd = 'SIGNAL' then
  208.             if find('ON OFF', upper(LkUp)) >0 then
  209.                LkUp = 'SIGTRAP'
  210.             else if pos('BREAK_', upper(LkUp)) = 1 then
  211.                 LkUp = 'BREAK_'
  212.             else
  213.                 LkUp = 'SIGTRAN'
  214.          when upper(LkUp) = 'UPPER' then
  215.             if Kwd ~= 'UPPER' then
  216.                LkUp = 'UPPER()'
  217.          when Kwd = 'ADDRESS' then
  218.              if abbrev(word(HLine, 2), LkUp) then do
  219.                  LkUp = Kwd
  220.                  leave CheckOpt  /* so we don't get address() */
  221.              end
  222.          otherwise
  223.       end
  224.       if GetXRef(LkUp'()') ~= 10 then
  225.          LkUp = LkUp'()'
  226.    end
  227. end
  228.  
  229.  
  230. if open(.GtEnv, 'env:arexxguide/agcmd', R) then do
  231.     AGCmd = readln(.GtEnv)
  232.     call close .GtEnv
  233. end
  234. else
  235.     signal NoCmd
  236.  
  237. if abbrev(AGCmd, 'Multi') then
  238.    PrtOpt = ''
  239. else
  240.    PrtOpt = 'portname ARX_GUIDE'
  241.  
  242. if GetXRef(LkUp) = 10 then
  243.    call ShowInfo HLine, LkUp, CurPos, Kwd
  244. else do
  245.       /* Show that we're doing something. Tells type of node being loaded */
  246.    'SetStatusBar ARexxGuide: 'upper(LkUp) '['word('Explanation Function Instruction', word(getxref(LkUp), 3)+1)']'
  247.  
  248.    Cmd = ''
  249.  
  250.       /* See if our AG window is open */
  251.    if ~show('P','ARX_GUIDE') then do
  252.       if Cmd = '' then
  253.          Cmd = 'run' AGCmd 'document' LkUp PrtOpt 'requester'
  254.  
  255.       address command cmd
  256.    end
  257.    else do
  258.  
  259.          /* What command do we use to show the node */
  260.       LinkCmd = "Link"
  261.       if mode = "ASYNC" then
  262.          LinkCmd = "ALink"
  263.  
  264.          /* show the node */
  265.       address ARX_GUIDE LinkCmd LkUp
  266.       address ARX_GUIDE 'unzoomwindow'
  267.       address ARX_GUIDE 'windowtofront'
  268.    end
  269. end
  270.  
  271. exit
  272.  
  273. XRefError:
  274.     ErrLine = SIGL
  275.     ErrMsg.0 = 5
  276.     ErrMsg.2 = 'Unable to load the cross-reference file ARx_Guide.xref'
  277.     if ~exists('env:amigaguide/path') then
  278.         ErrMsg.3 = 'Your environmental variable "amigaguide/path" is not set.'
  279.     else
  280.         ErrMsg.3 = '   Be sure to include that file''s directory in env:amigaguide/path.'
  281.     ErrMsg.4 = '   The .xref file may be put into the current directory or into'
  282.     ErrMsg.5 = '   any directory included in the amigaguide/path environmental variable.'
  283.     signal PutErrMsg
  284. NoCmd:
  285.     ErrLine = SIGL
  286.     ErrMsg.0 = 4
  287.     ErrMsg.2 = 'Can''t read environmental variable "env:arexxguide/AGcmd".'
  288.     ErrMsg.3 = '   That variable must hold the name of the command you use'
  289.     ErrMsg.4 = '   to show AmigaGuide files.'
  290.     signal PutErrMsg
  291. Syntax:
  292.     ErrLine = SIGL
  293.     ErrMsg.0 = 2
  294.     ErrMsg.2 = '   Syntax error #'rc ':' errortext(rc)
  295.     Signal PutErrMsg
  296. Failure:
  297.     ErrMsg.0 = 2
  298.     ErrMsg.2 = '   Command "'sourceline(SIGL)'" failed.'
  299.     ErrLine = SIGL
  300.     Signal PutErrMsg
  301. Halt:
  302. Break_C:
  303.     ErrMsg.0 = 2
  304.     ErrMsg.2 = '   Execution halted.'
  305.     ErrLine = SIGL
  306. PutErrMsg:
  307.     call trace b
  308.     ErrMsg.1 ='Sorry an enexpected error has occured in line' ErrLine'.'
  309.  
  310.     signal off syntax
  311.     signal off halt
  312.     signal off break_c
  313.     WinHi = 48 + ErrMsg.0 * 11
  314.     'SetStatusBar ARx_Help.ttx error.'
  315.     if open(.ErrWin, 'con:0/0/640/'WinHi'/Arx_Help Error/CLOSE') then do
  316.         do i = 1 to ErrMsg.0
  317.             call writeln(.ErrWin, ErrMsg.i)
  318.         end
  319.         call writech(.ErrWin, '0a'x'               Press <Enter>')
  320.         call readln(.ErrWin)
  321.     end
  322. exit 0
  323.  
  324. Tab2Space:  procedure
  325.    parse arg line
  326.    'GetPrefs tabwidth'
  327.    tabsize = result
  328.    tpos=pos('09'x,Line);
  329.    do while tpos>0;
  330.       Line=insert('',Line, tpos, min(1, tpos//tabsize)*(tabsize-tpos//tabsize));
  331.       tpos=pos('09'x, Line,tpos+1);
  332.    end;
  333. return translate(Line,' ','09'x)
  334.  
  335. /*  If you'd rather not use rexxarplib, or don't care to wait for all the **
  336. **  info collected in the subroutine, then you could uncomment this       **
  337. **  section. It's OK to leave the rest of the file in place, since ARexx  **
  338. **  will call only the first of two subroutines that use the same name.   **
  339. **  If you don't use it, though, this file will load faster if you get rid**
  340. **  of everthing below the 'return 0'                                     */
  341. /*
  342.   ShowInfo:
  343.  
  344.    'RequestBool "'center(upper(LkUp) 'not found.',37)'" "'center('Show ARexxGuide index?',37)'"'
  345.    if result = 'YES' then do
  346.       XMatch = TRUE; LkUp = 'ARx_Index/MAIN'
  347.       Cmd = 'run' AGCmd 'ARx_Index' PrtOpt 'requester'
  348.    end
  349. return 0
  350.  
  351. */
  352.  
  353. ShowInfo: procedure expose AGCmd
  354.  
  355.    parse arg HLine, LkUp, CurPos, Kwd
  356.       /* Show that we're doing something */
  357.    'SetStatusBar TEMPORARY "'LkUp'" not found. Checking clause...'
  358.  
  359.    if ~abbrev(AGCmd, 'Multi') then
  360.       ExecStr='ExecARexxString address ARXTTX quit; if ~show(P, ARX_GUIDE) then do;address command; run "'getenv("arexxguide/AGCmd") 'ARexxGuide.guide portname ARX_GUIDE";waitforport ARX_GUIDE; end; address ARX_GUIDE; windowtofront;'
  361.    else
  362.       ExecStr = 'ExecARexxString address ARXTTX quit; address command; run "'AGCmd'"ARexxGuide.guide"'
  363.  
  364.       /* figure out what type of clause the current line is */
  365.    select
  366.       when word(HLine, 2) = '=' then do
  367.          CType = 2
  368.       end
  369.       when pos('/*', HLine) < CurPos & pos('/*', HLine) ~= 0 then
  370.          if pos('*/', HLine) > CurPos | pos('*/', HLine) = 0 then
  371.             CType = 4
  372.       when getxref(word(HLine,1)) ~= 10 then do
  373.          Xref = getxref(word(HLine,1))
  374.          if word(Xref,3) = 2 then
  375.             CType = 1
  376.       end
  377.       when right(word(HLine,1), 1) = ':' then
  378.          CType = 3
  379.       when HLine = '' then
  380.          CType = 5
  381.       otherwise
  382.          CType = 0
  383.          EqPos = pos('=', HLine)
  384.          if EqPos > 0 then do
  385.             if symbol(strip(left(HLine, EqPos-1))) ~= 'BAD' then do
  386.                HLine=insert(' ', HLine, EqPos - 1)
  387.                HLine = insert(' ', HLine, EqPos + 2)
  388.                CType = 2
  389.             end
  390.          end
  391.    end
  392.    if CType = 2 then
  393.       if ~IsVar(word(HLine, 1)) then
  394.          CType = 0
  395.    /* Prepare the window gadgets */
  396.    CName.0 = 'Command'
  397.    CName.1 = 'Instruction'
  398.    CName.2 = 'Assignment'
  399.    CName.3 = 'Label'
  400.    CName.4 = 'Comment'
  401.    CName.5 = 'Null'
  402.    Gad. = ''
  403.    Gad.1.6Txt = 'Current clause is'
  404.    Gad.1.6Btn = CName.CType
  405.    Gad.1.6Cmd = ExecStr 'link' CName.CType
  406.    Gadgets = 1
  407.    select
  408.       when CType = 1 then do
  409.          Gad.2.6Txt = 'Current keyword is'
  410.          Gad.2.6Btn = Kwd
  411.          Gad.2.6Cmd = ExecStr 'link' Kwd
  412.          Gadgets = 2
  413.       end
  414.       when CType = 3 then do
  415.          Gad.2.6Txt = 'Name of subroutine:' word(HLine,1)'.'
  416.          Gadgets = 2
  417.       end
  418.           /* happens when cursor is at the end of a comment */
  419.       when ~datatype(CType, 'N') then
  420.           Gadgets = 0
  421.       otherwise
  422.    end
  423.  
  424.          /* Figure out what the current word is doing */
  425.          /* Use variables to make the bit settings more obvious */
  426.  
  427.    FuncName = 0; FuncArg = 1; Str = 2; Var = 3; Num=4; Hex=5; Bin=6; Cnst=7; Cmpd = 8
  428.    if CType <= 3 & LkUp > '' then do
  429.          /* Split the string so we can compare both sides */
  430.       parse var HLine LStr =CurPos RStr
  431.          /* Get only the portion of the string which contains LkUp */
  432.       WdRange = substr(HLine, max(1, CurPos - length(LkUp)), length(LkUp) *2)
  433.  
  434.          /* Use Bit functions to keep multiple matches */
  435.       WType = null()||null() /* Using more than 8 bytes */
  436.          /* Is it a string in single quotes ? */
  437.       if IsVar(LkUp) then do
  438.          WType = bitset(WType, Var)
  439.          if Kwd = 'CALL' then
  440.              if abbrev(word(HLine, 2), LkUp) then
  441.                  WType = bitset(WType, FuncName)
  442.              else
  443.                  WType = bitset(Wtype, FuncArg)
  444.       end
  445.       if verify(HLine, '"''', M) > 0 then do
  446.          if CountChar(LStr, "'")//2 then do
  447.             WType = bitset(WType, Str)
  448.                /* Is it a quoted function name? */
  449.             if pos(LkUp"'(", WdRange) & bittst(WType, Var) then
  450.                   WType = bitset(WType, FuncName)
  451.             else if datatype(LkUp, X) then
  452.                if pos(LkUp"'X", upper(HLine)) > 0 then
  453.                   WType = bitset(WType, Hex)
  454.             else if datatype(LkUp, B) then
  455.                if pos(LkUp"'B", upper(WdRange)) > 0 then
  456.                   WType = bitset(WType, Bin)
  457.          end
  458.             /* Is it a string in double quotes? */
  459.          else if CountChar(LStr, '"')//2 then do
  460.             WType = bitset(WType, Str)
  461.             if pos(LkUp'"(', WdRange) & bittst(WType, Var) then
  462.                   WType = bitset(WType, FuncName)
  463.             else if datatype(LkUp, X) then
  464.                if pos(LkUp'"X', upper(HLine)) then
  465.                   WType = bitset(WType, Hex)
  466.             else if datatype(LkUp, B) then
  467.                if pos(LkUp'"B', upper(WdRange)) > 0 then
  468.                   WType = bitset(WType, Bin)
  469.          end
  470.          if bittst(WType, Str) then
  471.             WType = bitclr(WType, Var)
  472.       end
  473.          /* Is current word enclosed in parens? */
  474.       if verify(HLine, "()", M) > 0 then do
  475.          if CountChar(LStr, "(") - CountChar(LStr, ")") > 0 then
  476.                WType = bitset(WType, FuncArg)
  477.          if pos(LkUp'(', WdRange) > 0 & bittst(WType, Var) then
  478.                WType = bitset(WType, FuncName)
  479.       end
  480.  
  481.          /* is it a number or constant? */
  482.       if datatype(LkUp, N) then do
  483.             /* Make sure it isn't already a hex or bin string */
  484.          if ~bittst(WType, Hex) & ~bittst(WType, Bin) then
  485.                WType = bitset(WType, Num)
  486.       end
  487.          /* compare String/Var. If it isn't one of those it's a constant */
  488.       else if ~bittst(WType, Var) then do
  489.          if ~bittst(WType, Str) then
  490.             WType = bitset(WType, Cnst)
  491.       end
  492.       else if pos('.', LkUp) > 0 then
  493.           WType = bitset(WType, Cmpd)
  494.          /* it could have been assigned FuncName in either check above **
  495.          ** In either case, a Function name isn't a variable           */
  496.       if bittst(WType, FuncName) then
  497.          WType = bitclr(WType, Var)
  498.       if CType = 3 then
  499.           if abbrev(Kwd, upper(LkUp)) then
  500.               WType = null()
  501.  
  502.          /** Prepare gadgets to explain current word **/
  503.       if WType ~= null() then do
  504.          interpret 'Gad.'Gadgets+1'.6Txt = ''"''Lkup''" is'''
  505.          if bittst(WType, FuncName) then do
  506.             Gadgets = Gadgets + 1
  507.             Gad.Gadgets.6Btn = 'Function name'
  508.             Gad.Gadgets.6Cmd = ExecStr 'link FUNCTION'
  509.          end
  510.          if bittst(WType, FuncArg) then do
  511.             Gadgets = Gadgets + 1
  512.             Gad.Gadgets.6Btn = 'Function argument'
  513.             Gad.Gadgets.6Cmd = ExecStr 'link FUNCARG'
  514.          end
  515.          if bittst(WType, Str) then do
  516.             Gadgets = Gadgets + 1
  517.             Gad.Gadgets.6Btn = 'String'
  518.             Gad.Gadgets.6Cmd = ExecStr 'link STRINGEXPR'
  519.          end
  520.          if bittst(WType, Hex) then do
  521.             Gadgets = Gadgets + 1
  522.             Gad.Gadgets.6Btn = 'Hex string'
  523.             Gad.Gadgets.6Cmd = ExecStr 'link HEXSTRING'
  524.          end
  525.          if bittst(WType, Bin) then do
  526.             Gadgets = Gadgets + 1
  527.             Gad.Gadgets.6Btn = 'Binary string'
  528.             Gad.Gadgets.6Cmd = ExecStr 'link HEXSTRING'
  529.          end
  530.          if bittst(WType, Var) then do
  531.             Gadgets = Gadgets + 1
  532.             Gad.Gadgets.6Btn = 'Variable'
  533.             Gad.Gadgets.6Cmd = ExecStr 'link VARIABLE'
  534.          end
  535.          if bittst(WType, Cmpd) then do
  536.             Gadgets = Gadgets + 1
  537.             Gad.Gadgets.6Btn= 'Compound variable'
  538.             Gad.Gadgets.6Cmd = ExecStr 'link COMPVAR'
  539.          end
  540.          if bittst(WType, Num) then do
  541.             Gadgets = Gadgets + 1
  542.             Gad.Gadgets.6Btn = 'Number'
  543.             Gad.Gadgets.6Cmd = ExecStr 'link NUMBER'
  544.          end
  545.          if bittst(WType, Cnst) then do
  546.             Gadgets = Gadgets + 1
  547.             Gad.Gadgets.6Btn = 'Constant symbol'
  548.             Gad.Gadgets.6Cmd = ExecStr 'link CONSTANT'
  549.          end
  550.       end
  551.    end
  552.       /* Open the rexxarplib requester window */
  553.    CPort = 'ARXTTX'
  554.    if ~InfoWin(CPort, Gadgets+2, 'Lookup:' LkUp) then return 10
  555.  
  556.  
  557.    x = 10; y = 32
  558.  
  559.    do i = 1 to Gadgets
  560.       move(CPort, x, y)
  561.       if Gad.i.6Btn = '' then
  562.          Txt = center(Gad.i.6Txt,47)
  563.       else
  564.          Txt = right(Gad.i.6Txt, 21)
  565.       call Text(CPort, Txt)
  566.       if Gad.i.6Btn > '' then
  567.          call AddGadget(CPort, 192, y - 9, i, ' 'left(Gad.i.6Btn, 26),Gad.i.6Cmd)
  568.       y = y + 15
  569.    end
  570.    call AddGadget(CPort, 10, y-4, 14, ' View ARexxGuide index ',ExecStr '"link Arx_Index/MAIN"')
  571.    call AddGadget(CPort, 344, y-4, 15, ' Cancel ', 'ExecARexxString address ARXTTX quit')
  572.  
  573.  
  574. return 0
  575.  
  576. InfoWin: procedure
  577.  
  578.    parse arg CPort, Rows, WinTitle
  579.  
  580.    PoC = address()
  581.       /** shut down previous requester if it's still around **/
  582.    if show(P, CPort) then do; address value CPort; quit; address; end
  583.    'GetWindowInfo'
  584.    x= word(result,3); y= word(result,3)
  585.    'GetScreenInfo'
  586.    PubScreen = word(result, words(result))
  587.       /* change notifyport (PoC) to a port read by this script */
  588.    address ARexx "'call CreateHost("CPort"," PoC", "PubScreen")'"
  589.       /**   Open the window   **/
  590.    idcmp = 'CLOSEWINDOW+GADGETUP'
  591.    flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH+ACTIVATE'
  592.    address command 'waitforport' CPort
  593.    Height = 16+15*Rows
  594.    if rc = 0 then do
  595.       call OpenWindow(CPort, x, y, 422, Height, idcmp,flags, WinTitle)
  596.       call SetAPen(CPort, 2)
  597.       call SetNotify(CPort, CLOSEWINDOW, CPort)
  598.       return 1
  599.    else
  600.       return 0
  601.  
  602. CountChar:
  603.  
  604.    parse arg IStr, Char
  605. return length(IStr) - length(compress(IStr, Char))
  606.  
  607. IsVar:
  608.    call trace b
  609.    return symbol(arg(1)) ~== 'BAD' & datatype(left(arg(1),1), m)
  610.  
  611.